home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
051-075
/
073
/
autoiconopen
/
autoiconopen.c
next >
Wrap
C/C++ Source or Header
|
1995-03-13
|
5KB
|
126 lines
/* PROGRAM : AutoIconOpen.c
AUTHOR : Tony (**all at sea in c**) Wills.
DATE : 15 FEB 87.
PURPOSE : To fool WorkBench into thinking it is recieving mouse inputs
that select & open icons.
Original application was to automatically open your disk icon
on bootup - and perhaps display instructions. For use in
our NewsDisk (=newsletter on a disk, along the lines of
JumpDisk and Amigazine).
This is a very simplistic program, and ignores all sorts of conventions
that might otherwise ensure it will work in many different environments.
(Just like the examples in the Amiga Technical manuals !!!, which this
program is based on.)
1) It assumes that the screen is 640x200 on startup
2) It assumes there is a cli window in front with it's bottom corner
at 640/400. It resizes this window to 540x200
3) This is expected to expose the disk icons residing in the top right
hand corner of the screen.
4) It opens the icon in the top righthand position by sending a double
click sequence.
5) All done, so closes input.device and exits.
Bugs, oversights, and possible improvements :
1) Doesn't allocate anything in public address space so won't work on
future hardware with a MMU that stops programs getting at others
address space - I'm sure that this is the least of this programs
problems!
2) I thought I was working on a 640x200 screen but have to move twice
as far vertically as I would expect!
3) Could string all events together using ie_NextEvent pointers, but not
much point for this application.
*/
#include <exec/types.h>
#include <exec/io.h>
#include <devices/input.h>
#include <exec/devices.h>
#include <devices/inputevent.h>
struct IOStdReq input_request_block;
struct InputEvent SimulatedEvent;
main()
{
if (OpenDevice("input.device",0,&input_request_block,0) != 0) {
exit(-1);
}
input_request_block.io_Command = IND_WRITEEVENT;
input_request_block.io_Flags = 0;
input_request_block.io_Length = sizeof(struct InputEvent);
input_request_block.io_Data = &SimulatedEvent;
/* Blat pointer into bottom, righthand corner, doesn't really matter where
we start from. I thought IECLASS_POINTERPOS or setting ie_Qualifier to
0 might give me absolute positioning - but didn't seem to do what I
expected. Press left button when you get there */
SimulatedEvent.ie_NextEvent = NULL;
SimulatedEvent.ie_Class = IECLASS_RAWMOUSE;
SimulatedEvent.ie_TimeStamp.tv_secs = 0;
SimulatedEvent.ie_TimeStamp.tv_micro = 0;
SimulatedEvent.ie_Code = IECODE_LBUTTON;
SimulatedEvent.ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;
SimulatedEvent.ie_X = 640;
SimulatedEvent.ie_Y = 400;
DoIO(&input_request_block);
/* Move left 100 while holding left button down, and release button - ie
resize the CLI window I expect to be there - If nothing's there then
it doesn't really matter! */
SimulatedEvent.ie_NextEvent = NULL;
SimulatedEvent.ie_Class = IECLASS_RAWMOUSE;
SimulatedEvent.ie_TimeStamp.tv_secs = 0;
SimulatedEvent.ie_TimeStamp.tv_micro = 0;
SimulatedEvent.ie_Code = IECODE_LBUTTON | IECODE_UP_PREFIX;
SimulatedEvent.ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;
SimulatedEvent.ie_X = -100;
SimulatedEvent.ie_Y = 0;
DoIO(&input_request_block);
/* Move to where I expect disk icon to be (595,22), but note I seem to
have to move to (595,45) as though the vertical resolution is double
what I think it is! */
SimulatedEvent.ie_NextEvent = NULL;
SimulatedEvent.ie_Class = IECLASS_RAWMOUSE;
SimulatedEvent.ie_TimeStamp.tv_secs = 0;
SimulatedEvent.ie_TimeStamp.tv_micro = 0;
SimulatedEvent.ie_Code = IECODE_NOBUTTON;
SimulatedEvent.ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;
SimulatedEvent.ie_X = 55;
SimulatedEvent.ie_Y = -355;
DoIO(&input_request_block);
/* Press left button without moving */
SimulatedEvent.ie_NextEvent = NULL;
SimulatedEvent.ie_Class = IECLASS_RAWMOUSE;
SimulatedEvent.ie_TimeStamp.tv_secs = 0;
SimulatedEvent.ie_TimeStamp.tv_micro = 0;
SimulatedEvent.ie_Code = IECODE_LBUTTON;
SimulatedEvent.ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;
SimulatedEvent.ie_X = 0;
SimulatedEvent.ie_Y = 0;
DoIO(&input_request_block);
/* Press left button again. Note I didn't release button in between but it
doesn't seem to matter! */
SimulatedEvent.ie_NextEvent = NULL;
SimulatedEvent.ie_Class = IECLASS_RAWMOUSE;
SimulatedEvent.ie_TimeStamp.tv_secs = 0;
SimulatedEvent.ie_TimeStamp.tv_micro = 0;
SimulatedEvent.ie_Code = IECODE_LBUTTON;
SimulatedEvent.ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;
SimulatedEvent.ie_X = 0;
SimulatedEvent.ie_Y = 0;
DoIO(&input_request_block);
/* All done so pack up and go home */
CloseDevice(&input_request_block);
}